<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>驳回产品</title>
    <script type="text/javascript">
      Ext.onReady(function(){
              var keys = <%= params[:id] %>;
              var rejectProductForm=new Ext.form.FormPanel({
                    width:600,
                    //labelAlign: 'top',
                    
                    buttonAlign:'center',
                    autoHeight:true,
                    fileUpload: true,
                    bodyStyle: 'padding:5px',
                    labelWidth:100,
                    waitMsgTarget: true,
                    frame: true,
                    items:[{
                          layout:'column',
                          items:[{
                              columnWidth:1,
                              layout:'form',
                              labelAlign: 'top',
                              items:[{
                                  xtype:'textarea',
                                  fieldLabel: '驳回原因',
                                  name: 'reject_reason',
                                  allowBlank:false,
                                  height:150,
                                  anchor: '95%'
                              }]
                          }]
                     }],
                     buttons:[{
                        text:'确定',
                        handler: function(){
                            // check form value
                            Ext.MessageBox.confirm('警告','确定驳回该产品？',function(button){
                              if(button=='yes'){
                                if (rejectProductForm.form.isValid()) {
                                  rejectProductForm.form.submit({
                                    method: 'post',
                                    url:'/product/rejectProduct?id='+keys,
                                    waitMsg: '正在保存驳回原因...',
                                    success: function(result, response){
                                      if (response.result.info == "success") {
                                        //添加成功后，隐藏窗口，并刷新Grid
                                        Ext.MessageBox.alert('消息', '已经成功驳回产品');
                                        rejectProductWin.destroy();
                                      }else {
                                        Ext.MessageBox.alert('消息', response.result.info);
                                      }
                                    },
                                    failure: function(result, response){
                                      Ext.MessageBox.alert('提示', result.responseText);
                                    }
                                  });
                                }
                                else {
                                  Ext.MessageBox.alert('错误提示', '请按要求填写必输选项.');
                                }
                              }
                            })
                          }
                    },{
                        text:'取消',
                        handler:function(){
                            rejectProductWin.destroy();
                        }
                    }]
                });
          rejectProductForm.render('reject_product_form');
      })
    </script>
  </head>
  <body>
     <div id="reject_product_form"></div>
  </body>
</html>
